﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Xyz.DataObjects.Interfaces;

namespace Xyz.DataObjects.Entity.Dao
{
    public class EntityRoleDao : IRoleDao
    {
        public string GetCustomerRole(string userName)
        {
            using (var context = EntityObjectFactory.CreateContext())
            {
                var customer =
                    context.CustomerEntities.SingleOrDefault(x => x.UserName == userName);

                var role = context.RoleEntities.Single(x => x.RoleId == customer.RoleId);

                if (role != null)
                {
                    return role.RoleName;
                }
            }

            return string.Empty;
        }
    }
}
